package com.td.evo.log;

import com.krakers.evo.obj.DNA;
import com.td.core.obj.TDMap;

public class TDPathEvolutionLogic implements TDMap {

	private static final int X = BLD_X/2;
	
	/**
	 * Fills specified row with ones.
	 * @param dna
	 * @param row
	 */
	public static void fillOnes(DNA dna, int row) {
		for(int i = 0; i < X; i++) {
			dna.setGene(X*row+i, 1);
		}
	}
	
	/**
	 * Fills specified part of row with zeros.
	 * @param dna
	 * @param row
	 * @param z1	start/end indx
	 * @param z2	start/end indx
	 */
	public static void fillZeros(DNA dna, int row, int z1, int z2) {
		if(z1 < z2) {
			for(int i = z1; i <= z2; i++) {
				dna.setGene(X*row+i, 0);
			}
		} else {
			for(int i = z2; i <= z1; i++) {
				dna.setGene(X*row+i, 0);
			}
		}
	}
	
	/**
	 * Gets first zero from specified row.
	 * @param dna
	 * @param row
	 * @return
	 */
	public static int getZeroIndx(DNA dna, int row) {
		for(int i = 0; i < X; i++) {
			if(dna.getGene(X*row + i) == 0)
				return i;
		}
		return -1;
	}
	
}
